<?php


namespace App\Controller;

use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\GetMapping;
use Hyperf\Utils\Context;

/**
 * @Controller()
 */
class ContextTestController extends AbstractController
{
    private $cc;


    /**
     * @GetMapping(path="/context/get")
     */
    public function getContext()
    {
        return [
            'context' => Context::get(self::getContextKey('cc')),
            'mem'     => $this->cc,
        ];
        return $this->response->json([
            'context' => Context::get(self::getContextKey('cc')),
            'mem'     => $this->cc,
        ]);
    }

    /**
     * @GetMapping(path="/context/update")
     */
    public function updateContext()
    {
        $cc = $this->request->input('cc', null);
        $this->cc = $cc;

        return [
            'context' => Context::set(self::getContextKey('cc'), $cc),
            'mem'     => $this->cc,
        ];
        return $this->response->json([
            'context' => Context::set(self::getContextKey('cc'), $cc),
            'mem'     => $this->cc,
        ]);
    }
}